<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		
		<script>
			
			window.onload = function() {
				var oInput = document.getElementsByTagName("input")[0];
				
				//给oInput元素节点添加一个点击事件
				oInput.onclick = function() {
					
					var arr = ["red", "blue", "green", "yellow", "orange", "white", "pink"];
					var oBox = document.getElementById("box");
					
					//开启定时器
					var i = 0;
					setInterval(function(){
						//i++;
						oBox.style.backgroundColor = arr[++i % 7];
						
					}, 1000);
					
					
				}
			}
			
			
		</script>
		
	</head>
	<body>
		
		<div id="box" style="background: red; width: 100px; height: 100px; "></div>
		<input type="button" value="点击改变颜色" />
		
	</body>
</html>
